<template>
  <div class="container">
    <city-header></city-header>
    <city-search :cities="cities"></city-search>
    <city-list :cities="cities" :hotCities="hotCities" :letter="letter"></city-list>
    <city-alphabet :cities="cities" @change="handleLetterChange"></city-alphabet>
  </div>
</template>

<script>
import CityHeader from './header/header'
import CitySearch from './search/Search'
import CityList from './list/List'
import CityAlphabet from './alphabet/Alphabet'
import axios from 'axios'
export default {
  data () {
    return {
      cities: {},
      hotCities: [],
      letter: ''
    }
  },
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  methods: {
    getInfo () {
      axios.get('/api/city.json').then(res => {
        this.cities = res.data.data.cities
        this.hotCities = res.data.data.hotCities
      })
    },
    handleLetterChange (letter) {
      this.letter = letter
    }
  },
  mounted () {
    this.getInfo()
  }
}
</script>

<style scoped lang="stylus">
  .container
    touch-action: none
</style>
